//
//  DropdownMenuViewUtil.m
//  YiJuZhangShou2.0
//
//  Created by URANUS on 16/3/28.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "DropdownMenuViewUtil.h"
#import "Masonry.h"
#import "UILabel+XExtension.h"

@implementation DropdownMenuViewUtil
#pragma mark - Public
+ (DropdownMenuView *)loadDropdownMenuViewWithTitle:(NSString *)title withDropdownMenuContentTitleArray:(NSArray *)menuTitles andBackView:(UIView *)backView{
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = title;
    titleLabel.textColor = TextColor80;
    titleLabel.tag = 1;
    titleLabel.font = TextFont14;
    DropdownMenuView *dropdownMenuView = [[DropdownMenuView alloc] initWithTitles:menuTitles];
    dropdownMenuView.textColor = TextColor120;
    dropdownMenuView.textFont = TextFont14;
    [backView addSubview:dropdownMenuView];
    [backView addSubview:titleLabel];
    
    CGRect tmpRect = [titleLabel calculateBounds];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backView).offset(5);
        make.centerY.equalTo(backView);
        make.width.equalTo(tmpRect.size.width);
    }];
    [dropdownMenuView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(backView);
        make.top.bottom.equalTo(backView);
        make.right.equalTo(backView);
    }];
    
    return dropdownMenuView;
}
@end
